package com.itm.lqm.servlets.course;

import java.io.IOException;





import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


import com.itm.lqm.entity.Course;
import com.itm.lqm.entity.Grade;
import com.itm.lqm.service.CourseService;
import com.itm.lqm.service.GradeService;



/**
 * Servlet implementation class FinalStudent
 */
@WebServlet("/findAllCourse")
public class findAllCourse extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public findAllCourse() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding("UTF-8");
		response.setCharacterEncoding("UTF-8");
		response.setContentType("text/html; charset=UTF-8");
		
		//查询课程
		CourseService  cs=new CourseService();
		List<Course> list=cs.findCourseAll();
		request.getSession().setAttribute("course", list);
		//查询成绩
		GradeService  cs1=new GradeService();
		List<Grade> grade=cs1.findGradeAll();
		request.getSession().setAttribute("grade", grade);
		
		
		//。。。。。。。。。。。。。。
//		int gid=Integer.parseInt(request.getParameter("gid"));//强制转换类型
//		System.out.println(gid);
		GradeService ts=new GradeService();
		Grade g= ts.findGradeBygid(1);
		//System.out.println("dedao"+c);
		request.setAttribute("g", g);
		
		//System.out.println("se"+list);
		//request.getRequestDispatcher("course.jsp").forward(request, response);
		request.getRequestDispatcher("TeaIndex.jsp").forward(request, response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding("UTF-8");
		response.setCharacterEncoding("UTF-8");
		response.setContentType("text/html; charset=UTF-8");
		
		//CourseDao cd=new CourseDao();
		CourseService  cs=new CourseService();
		List<Course> list=cs.findCourseAll();
		request.getSession().setAttribute("course", list);
		//System.out.println("se"+list);
		request.getRequestDispatcher("TeaIndex.jsp").forward(request, response);
		//request.getRequestDispatcher("course.jsp").forward(request, response);
	}
		

}
